#!/usr/bin/env perl

# Simple program that takes a filename, (hopefully) parses the freeform
# Changes file and prints the YAML version to STDOUT.

use warnings;
use strict;
use Module::Changes;
use Getopt::Attribute;

our $author : Getopt(author|a=s);

my $filename = shift;
$filename = 'Changes' unless defined($filename) && length $filename;

my $parser = Module::Changes->make_object_for_type('parser_free');
my $formatter = Module::Changes->make_object_for_type('formatter_yaml');

my $changes = $parser->parse_from_file($filename);

if (defined($author) && length $author) {
    $_->author($author) for $changes->releases;
}

print $formatter->format($changes);

